<?php
namespace App\Http\Controllers\Common\Traits;

use Illuminate\Support\Facades\Auth;

/**
 * 平台端
 * Trait AdminUserAuthTrait
 * @package App\APIs\V1\Controllers\Traits
 */
trait AdminUserAuthTrait
{
    /**
     * 获取API登录的用户认证信息
     * @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard|mixed
     * User: zhouteng
     */
    public function guard()
    {
        return Auth::guard('admin');
    }

    /**
     * 获取用户模型
     * @return \Illuminate\Contracts\Auth\Authenticatable|null
     * User: zhouteng
     */
    public function userModel()
    {
        return $this->guard()->user();
    }

    /**
     * 获取用户ID
     * @return int|null
     * User: zhouteng
     */
    public function userId()
    {
        return $this->userModel()->id;
    }

}